"""处理时间格式的函数"""
def sanitize(time_string):
    if "-" in time_string:
        spliter = "-"
    elif ":" in time_string:
        spliter = ":"
    else:
        return time_string
    (mins, secs) = time_string.split(spliter)
    return mins + '.' + secs


"""读取文件内容"""
def get_file_data(filename):
    try:
        with open(filename) as files:
            data = files.readline()
            return data.strip().split(",")
    except IOError as err:
        print("File Error" + err)


sa_list = get_file_data("F:/data/file7/sa.txt")
# (sa_name, sa_dob) = sa_list.pop(0), sa_list.pop(0)
#
# print(sa_name + " fast time is:" +
#       str(sorted(set([sanitize(t) for t in sa_list]), reverse=True)[0:3]))
#

# 使用dict
sa_data = {'Name': sa_list.pop(0), 'Dob': sa_list.pop(0), 'Times': sa_list}

print(sa_data['Name'] + " fast times is :" +
      str(sorted(set([sanitize(t) for t in sa_data['Times']]), reverse=True)[0:3]))


